
package sourceFiles;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import Exceptions.*;
import Exceptions.CentralComputerExceptions.*;

/**
 * A class responsible for all Central Computer functionality in E-Park system. 
 * The central computer gets requests from all the components in the system and operate them.
 * The requests can come from: 
 * 1. the Supervisor Station - to add/update the park's rides.
 * 2. the Registration Station - to register new guardians and their children and save their details to 
 * the park system.
 * 3. the User Application - to connect a guardian to the system and buy/cancel rides tickets.
 * 4. the Entrance/Exit from rides station - to check if it's possible to entrance/exit from the ride 
 * and all other relevant parameters. 
 *
 * 
 * @author LASO-Team
 * 
 */

public interface ICentralComputer {

	/**
	 * The method creates new ride in the E-Park system.
	 * @param rideName 
	 * 			the ride's name.
	 * @param isExtremeRide
	 * 			marks if a ride is extreme ride.
	 * @param maxCapacity
	 * 			the maximum capacity of the ride.
	 * @param minAge
	 * 			the minimal age of the ride.
	 * @param minHeight
	 * 			the minimal height of the ride.
	 * @return
	 * 			the system generates a ride's ID.
	 * @throws InvalidRideName
	 * 			if invalid name.
	 * @throws InvalidCapacity
	 * 			if invalid capacity.
	 * @throws InvalidAgeParam
	 * 			if invalid age.
	 * @throws InvalidHeightParam
	 * 			if invalid height.
	 * @throws XMLRidesParserException
	 * 			if invalid xml parser.
	 */

	public Integer createRide(String rideName, Boolean isExtremeRide,
			Integer maxCapacity, Integer minAge, Integer minHeight)
			throws InvalidRideName, InvalidCapacity, InvalidAgeParam,
			InvalidHeightParam, XMLRidesParserException;

	/**
	 * The method updates a ride in the E-Park system by it's ID.
	 * @param rideID
	 * 			the ride's park ID.
	 * @param maxCapacity
	 * 			the maximum capacity of the ride.
	 * @param minAge
	 * 			the minimal age of the ride.
	 * @param minHeight
	 * 			the minimal height of the ride.
	 * @throws InvalidRideId
	 * 			if invalid ride's ID.
	 * @throws InvalidCapacity
	 * 			if invalid capacity.
	 * @throws InvalidAgeParam
	 * 			if invalid age.
	 * @throws InvalidHeightParam
	 * 			if invalid height.
	 * @throws RideIDDoesntExist
	 * 			if the ride ID doesn't exist.
	 * @throws XMLRidesParserException
	 * 			if invalid xml parser.
	 */
	public void updateRide(Integer rideID, Integer maxCapacity, Integer minAge,
			Integer minHeight) throws InvalidRideId, 
			InvalidCapacity, InvalidAgeParam, InvalidHeightParam,
			RideIDDoesntExist, XMLRidesParserException;

	/**
	 * The method adds new guardian to the E-Park system.
	 * @param guardianID
	 * 			the guardian's ID.
	 * @param billingInfo
	 * 			the billing information - credit card number.
	 * @return
	 * 			the system generates a password for the guardian.
	 * @throws GuardianAlreadyExist
	 * 			if the guardian already exist in the E-Park system.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID invalid.
	 */
	public String addGuardian(Integer guardianID, Integer billingInfo)
			throws GuardianAlreadyExist, InvalidGuardianID;

	/**
	 * The method adds new child to his guardian that already registered to the E-Park system.
	 * @param guardianID
	 * 			the guardian's ID.
	 * @param childID
	 * 			the child's ID.
	 * @param age
	 * 			the child's age.
	 * @param height
	 * 			the child's height.
	 * @throws GuardianIDDoesntExist
	 * 			if the guardian does not exist in the E-Park system.
	 * @throws InvalidHeightParam
	 * 			if invalid height.
	 * @throws InvalidAgeParam
	 * 			if invalid age.
	 * @throws ChildAlreadyExist
	 * 			if the child already exist in the E-Park system.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID invalid.
	 * @throws InvalidChildID
	 * 			if the child's ID invalid.
	 */
	public void addChildToGuardian(Integer guardianID, Integer childID,
			Integer age, Integer height) throws GuardianIDDoesntExist,
			InvalidHeightParam, InvalidAgeParam, ChildAlreadyExist,
			InvalidGuardianID, InvalidChildID;

	/**
	 * The method connects the guardian to the user application.
	 * @param userID
	 * 			the guardian's ID.
	 * @param userPassword
	 * 			the guardian's password.
	 * @throws InvalidPassword
	 * 			if the password invalid.
	 * @throws GuardianIDDoesntExist
	 * 			if the guardian does not exist in the E-Park system.
	 * @throws ErrorInGuardianPassword
	 * 			if the password is incorrect.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID invalid.
	 */
	public void connectGuardian(Integer userID, String userPassword)
			throws InvalidPassword, GuardianIDDoesntExist,
			ErrorInGuardianPassword, InvalidGuardianID;

	/**
	 * The method performs the billing process and adds a chosen ride's ticket to chosen child's E-Ticket.
	 * @param rideID
	 * 			the ride's ID.
	 * @param guardianID
	 * 			the guardian's ID.
	 * @param childID
	 * 			the child's ID.
	 * @throws InvalidRideId
	 * 			if the ride's ID is invalid.
	 * @throws ChildIDDoesntExist
	 * 			if the child does not exist in the E-Park system.
	 * @throws RideIDDoesntExist
	 * 			if the ride does not exist in the E-Park system.
	 * @throws GuardianIDDoesntExist
	 * 			if the guardian does not exist in the E-Park system.
	 * @throws InvalidChildID
	 * 			if the child's ID is invalid.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID is invalid.
	 */
	public void buyingProcess(Integer rideID, Integer guardianID,
			Integer childID) throws InvalidRideId, ChildIDDoesntExist,
			RideIDDoesntExist, GuardianIDDoesntExist, InvalidChildID,
			InvalidGuardianID;

	/**
	 * This method simulates connection with credit company.
	 * @param ridePrice
	 * 			the ride's price.
	 * @param billingInfo
	 * 			the billing information.
	 */
	public void performBilling(Double ridePrice, Integer billingInfo);


	/**
	 * The method cancels acquisition of ride. remove the chosen ride's ticket from the chosen child's E-Ticket.
	 * @param rideID
	 * 			the ride's ID.
	 * @param guardianID
	 * 			the guardain's ID.
	 * @param childID
	 * 			the child's ID.
	 * @throws InvalidRideId
	 * 			if the ride's ID is invalid.
	 * @throws ChildIDDoesntExist
	 * 			if the child does not exist in the E-Park system.
	 * @throws RideIDDoesntExist
	 * 			if the ride does not exist in the E-Park system.
	 * @throws TicketDoesntExist
	 * 			if the ticket does not exist.
	 * @throws GuardianIDDoesntExist
	 * 			if the guardian does not exist in the E-Park system.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID is invalid.
	 * @throws InvalidChildID	
	 * 			if the child's ID is invalid.
	 */
	public void cancelAcquisition(Integer rideID, Integer guardianID,
			Integer childID) throws InvalidRideId, ChildIDDoesntExist,
			RideIDDoesntExist, TicketDoesntExist, GuardianIDDoesntExist,
			InvalidGuardianID, InvalidChildID;

	/**
	 * The method validates the child's parameters before he entrance a ride.
	 * @param rideID
	 * 			the ride's ID.
	 * @param childID
	 * 			the child's ID.
	 * @throws RideIDDoesntExist
	 * 			if the ride does not exist in the E-Park system.
	 * @throws ChildIDDoesntExist
	 * 			if the child does not exist in the E-Park system.
	 * @throws ChildAgeDoesntMatch
	 * 			if the child's age does not match the ride's age limitation.
	 * @throws ChildHeightDoesntMatch
	 * 			if the child's height does not match the ride's age limitation.
	 * @throws TicketDoesntExist
	 * 			if the ticket does not exist.
	 * @throws ChildDoesntHaveTicket
	 * 			if the ride's ticket does not exist in the E-Ticket of the child.
	 * @throws InvalidChildID
	 * 			if the child's ID invalid.
	 * @throws InvalidRideId
	 * 			if the ride's ID invalid.
	 */
	public void validateChildForRide(Integer rideID, Integer childID)
			throws RideIDDoesntExist, ChildIDDoesntExist, ChildAgeDoesntMatch,
			ChildHeightDoesntMatch, TicketDoesntExist, ChildDoesntHaveTicket,
			InvalidChildID, InvalidRideId;

	/**
	 * The methods retrieves the guardian's children position in E-Park's rides.
	 * @param guardinID
	 * 			the guardain's ID.
	 * @return
	 * 			a Map collection: the key is the child's ID, and the value is the ride's ID.
	 * @throws GuardianIDDoesntExist
	 * 			if the guardian does not exist in the E-Park system.
	 * @throws NoChildrenForGuardian
	 * 			if there is no children for guardian.
	 * @throws InvalidGuardianID
	 * 			if the guardian's ID is invalid.
	 */
	public Map<Integer, Integer> retrieveChildrenLocation(Integer guardinID)
			throws GuardianIDDoesntExist, NoChildrenForGuardian, InvalidGuardianID;

	/**
	 * The method retrieves the child's E-Ticket.
	 * @param childID
	 * 			the child's ID.
	 * @return
	 * 			the E-Ticket of the child by his ID.
	 * @throws ChildIDDoesntExist
	 * 			if the child does not exist in the E-Park system.
	 * @throws InvalidChildID
	 * 			if the child's ID is invalid.
	 */
	public ETicket retrieveChildETicket(Integer childID)
			throws ChildIDDoesntExist, InvalidChildID;

//	/**
//	 * @param childID
//	 */
	// public void childLeavesRide(Integer childID);

	/**
	 * parser getter
	 * @return the parser
	 */
	public XMLRidesParser getParser();

	/**
	 * parser setter
	 * @param parser
	 *            the parser to set
	 */
	public void setParser(XMLRidesParser parser);

	/**
	 * gets the Map with rides's IDs and the number of sold tickets for each ride.
	 * @return the ticketsSold
	 */
	public HashMap<Integer, Integer> getTicketsSold();

	/**
	 * sets the Map with rides's IDs and the number of sold tickets for each ride.
	 * @param ticketsSold
	 *            the ticketsSold to set
	 */
	public void setTicketsSold(HashMap<Integer, Integer> ticketsSold);

	/**
	 * supervisor station getter.
	 * @return the supervisorStation
	 */
	public SupervisorStation getSupervisorStation();

	/**
	 * supervisor station setter.
	 * @param supervisorStation
	 *            the supervisorStation to set
	 */
	public void setSupervisorStation(SupervisorStation supervisorStation);

	/**
	 * gets the guardians list in the E-Park system.
	 * @return the guardiansList
	 */
	public LinkedList<GuardianEntry> getGuardiansList();

	/**
	 * sets the guardians list in the E-Park system.
	 * @param guardiansList
	 *            the guardiansList to set
	 */
	public void setGuardiansList(LinkedList<GuardianEntry> guardiansList);

	/**
	 * gets the children list in the E-Park system.
	 * @return the childrenList
	 */
	public LinkedList<ChildEntry> getChildrenList();

	/**
	 * sets the children list in the E-Park system.
	 * @param childrenList
	 *            the childrenList to set
	 */
	public void setChildrenList(LinkedList<ChildEntry> childrenList);

	/**
	 * gets the rides list in the E-Park system.
	 * @return the ridesList
	 */
	public LinkedList<IRide> getRidesList();

	/**
	 * sets the rides list in the E-Park system.
	 * @param ridesList
	 *            the ridesList to set
	 */
	public void setRidesList(LinkedList<IRide> ridesList);

	/**
	 * gets the rides catalog (with price parameter).
	 * @return the ridesCatalog
	 */
	public LinkedList<RideEntry> getRidesCatalog();

	/**
	 * sets the rides catalog (with price parameter).
	 * @param ridesCatalog
	 *            the ridesCatalog to set
	 */
	public void setRidesCatalog(LinkedList<RideEntry> ridesCatalog);

}